package com.pro.wallet.base;

import com.hashkey.wxbasemodule.utils.LogUtil;
import com.pro.wallet.config.AppConfig;

import java.util.UUID;

import io.flutter.app.FlutterApplication;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.FlutterEngineCache;
import io.flutter.embedding.engine.dart.DartExecutor;

public class WalletApplication extends FlutterApplication {
    @Override
    public void onCreate() {
        super.onCreate();

     }

    // 引擎初始化
    private void flutterEngineInit() {
        AppConfig.mainEngineId = UUID.randomUUID().toString();

        LogUtil.i("engine====", AppConfig.mainEngineId);

        engineInit(AppConfig.mainEngineId, AppConfig.FlutterConfig.FLUTTER_INIT_ROUTE_MAIN);
    }

    private void engineInit(String engineId, String initRoute) {
        FlutterEngine flutterEngine = new FlutterEngine(this);

        flutterEngine.getNavigationChannel().setInitialRoute(initRoute);

        flutterEngine.getDartExecutor().executeDartEntrypoint(
                DartExecutor.DartEntrypoint.createDefault()
        );

        FlutterEngineCache.getInstance().put(engineId, flutterEngine);
    }
}
